      1  import org.junit.Test;

      2  import org.junit.Assert;

      3

      4  public class CashRegisterTest

      5  {

      6     private static final double EPSILON = 1E-12;

      7

      8     @Test public void twoPurchases()

      9     {

     10        CashRegister register = new CashRegister();

     11        register.recordPurchase(0.75);

     12        register.recordPurchase(1.50);

     13        register.receivePayment(2, 0, 5, 0, 0);

     14        double expected = 0.25;

     15        Assert.assertEquals(expected, register.giveChange(), EPSILON);

     16     }

     17

     18     @Test public void testZeroBalance()

     19     {

     20        CashRegister register = new CashRegister();

     21        register.recordPurchase(2.25);

     22        register.recordPurchase(19.25);

     23        register.receivePayment(21, 2, 0, 0, 0);

     24        Assert.assertEquals(0, register.giveChange(), EPSILON);

     25     }

     26

     27     // More test cases

     28     // . . .

     29  }